<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>用户信息管理</title>
    <#include "../../common/link.ftl">
    <link rel="stylesheet" type="text/css" href="/js/plugins/bootstrap-select/bootstrap-select.css"/>
    <script src="/js/plugins/bootstrap-select/bootstrap-select.js"></script>
    <script>
        $(function () {
            // 日期插件
            $('.input-daterange').datepicker({
                language: "zh-CN",
                autoclose: true,
                todayHighlight: true,
                clearBtn: true
            });

            //全选/全不选
            $("#allCb").click(function () {
                //获取当前复选框checked状态,设置到table中的所有复选框
                $(".cb").prop('checked',$(this).prop('checked'))
            })

            //table中的复选框
            $(".cb").click(function () {
                //获取table中已经勾选的复选框的数量 , 判断是否等于table中的所有复选框的数量
                $("#allCb").prop('checked',$(".cb:checked").length == $(".cb").length)
            })

            //批量删除
            $(".btn_batchDelete").click(function () {
                //获取勾选的数据
                //判断是否有选中,如果没有需要先提示选中
                if($(".cb:checked").length == 0){
                    $.messager.alert("警告","请先选中数据!");
                    return;
                }
                //把选中的员工的id存到在ids
                var cbs = $(".cb:checked");
                var ids = [];
                $.each(cbs,function (index, ele) {
                    ids.push($(ele).data('id'));
                })

                //如果有,提示确认框是否删除
                $.messager.confirm("警告","请确认是否进行删除?",function () {
                    $.post('/user/batchDelete.do',{ids:ids},handlerMessage)
                })
            })

            //批量审核
            $(".btn_batchdo").click(function () {
                //获取勾选的数据
                //判断是否有选中,如果没有需要先提示选中
                if($(".cb:checked").length == 0){
                    $.messager.alert("警告","请先选中数据!");
                    return;
                }
                //把选中的员工的id存到在ids
                var cbs = $(".cb:checked");
                var ids = [];
                var assoids = [];
                $.each(cbs,function (index, ele) {
                    ids.push($(ele).data('id'));
                    assoids.push($(ele).data('asso'));
                })
                //如果有,提示确认框是否删除
                $.messager.confirm("提示","是否全部审批通过?",function () {
                    $.post('/member/bitchPass.do',{ids:ids,assoids:assoids},handlerMessage)
                })
            })

            // 审核通过
            $(".hotBtn1").click(function () {   // 审核通过
                var hot = $(this).data("hot");
                var id = $(this).data("id");
                var assoId = $(this).data("asso");
                $.get("/member/passOne", {hot:hot, id:id,assoId:assoId}, function (data) {
                    if(data.code == 200){
                        window.location.reload();
                    }else{
                        $.messager.alert("温馨提示", data.msg);
                    }
                })
            })
            // 审核拒绝
            $(".hotBtn2").click(function () {   // 审核拒绝
                var hot = $(this).data("hot");
                var id = $(this).data("id");
                var assoId = $(this).data("asso");
                console.log(assoId)
                $.get("/member/passOne", {hot:hot, id:id,assoId:assoId}, function (data) {
                    if(data.code == 200){
                        window.location.reload();
                    }else{
                        $.messager.alert("温馨提示", data.msg);
                    }
                })
            })

            //导入按钮
            $(".btn-import").click(function () {
                $("#myModal").modal('show');
            });

            // 批量审核
            $(".btn_batchPass").click(function () {
                //获取勾选的数据
                //判断是否有选中,如果没有需要先提示选中
                if($(".cb:checked").length == 0){
                    $.messager.alert("警告","请先选中数据!");
                    return;
                }
                //把选中的员工的id存到在ids
                var cbs = $(".cb:checked");
                var ids = [];
                $.each(cbs,function (index, ele) {
                    ids.push($(ele).data('id'));
                })
                //如果有,提示确认框是否删除
                $.messager.confirm("提示","是否全部审批通过?",function () {
                    $.post('/member/bitchPass.do',{ids:ids},handlerMessage)
                })
            })

            // 新增/编辑按钮点击事件
            $(".btn_redirect").click(function () {
                //清除模态框的数据
                //数据复原
                $("#myModalSynLabel").html("社团成员新增");
                $("#editForm2").clearForm(true);

                var json = $(this).data("json");
                console.log(json)
                $("#editForm2 select[name='isAgree']").val(-1)
                if(json){ //json有数据代表是编辑
                    $("#myModalSynLabel").html("社团成员编辑");
                    $("#editForm2 input[name='id']").val(json.id);
                    $("#editForm2 input[name='relationId']").val(json.relationId);
                    $("#editForm2 input[name='number']").val(json.number);
                    $("#editForm2 input[name='name']").val(json.name);
                    $("#editForm2 input[name='deptname']").val(json.deptname);
                    $("#editForm2 select[name='isAgree']").val(json.isAgree);
                    $("#editForm2 input[name='passTime']").val(json.passTime);
                }

                //打开模态框
                $("#inputSynModal").modal('show');
            });

            // 保存: 新增/编辑
            $(".btn-submit2").click(function () {
                $("#editForm2").ajaxSubmit(function (data) {
                    if(data.code == 200){
                        window.location.reload();
                    }else{
                        $.messager.alert("温馨提示", data.msg);
                    }
                })
            });
        })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../../common/navbarAsso.ftl">
    <!--菜单回显-->
    <#assign currentMenu="member"/>
    <#include "../../common/menuAsso.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>社团成员信息管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <div style="margin: 10px;">
                    <form class="form-inline" id="searchForm" action="/member/listAsso.do" method="post">
                        <input type="hidden" name="currentPage" id="currentPage" value="1">
                        <div class="form-group">
                            <label for="keyword">关键字:</label>
                            <input type="text" class="form-control" id="keyword" name="keyword" value="${qo.keyword!}" placeholder="请输入姓名/邮箱/班级">
                        </div>
                        <div class="form-group">
                            <label for="keyword">学号:</label>
                            <input type="text" class="form-control" id="num" name="num" value="${qo.num!}" placeholder="请输入学号">
                        </div>
                        <div class="form-group">
                            <label for="keyword">部门:</label>
                            <input type="text" class="form-control" id="depat" name="depat" value="${qo.depat!}" placeholder="请输入所属部门名称">
                        </div>
                        <div class="form-group">
                            <label for="status"> 审核:</label>
                            <select class="form-control" id="status" name="status">
                                <option value="-1">全部</option>
                                <option value="0">待审核</option>
                                <option value="1">审核通过</option>
                                <option value="2">审核拒绝</option>
                            </select>
                            <script>
                                $("#status").val(${qo.status!});
                            </script>
                        </div>
                        <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询</button>

                        <a href="JavaScript:;" class="btn btn-danger  btn_batchDelete">
                            <span class="glyphicon glyphicon-trash"></span> 批量删除
                        </a>

                        <a href="/member/exportXls2.do" class="btn btn-warning" >
                            <span class="glyphicon glyphicon-download"></span> 导出
                        </a>

                        <a href="JavaScript:;" class="btn btn-warning btn-import">
                            <span class="glyphicon glyphicon-upload"></span> 导入
                        </a>

                        <a href="JavaScript:;" class="btn btn-success  btn_batchPass">
                            <span class="glyphicon glyphicon-check"></span> 批量审核
                        </a>

                    </form>
                </div>
                <table class="table table-hover table-bordered">
                    <thead>
                    <tr>
                        <th><input type="checkbox" id="allCb"></th>
                        <th>序号</th>
                        <th>图片</th>
                        <th>学号</th>
                        <th>姓名</th>
                        <th>学院</th>
                        <th>专业</th>
                        <th>班级</th>
                        <th>性别</th>
                        <th>生日</th>
                        <th>联系方式</th>
                        <th>邮箱</th>
                        <th>部门</th>
                        <th>入会时间</th>
                        <th>状态</th>
                        <th>操作</th>
                        <th>审核</th>
                    </tr>
                    </thead>
                    <#list page.list as member>
                        <tr>
                            <td><input type="checkbox" class="cb" data-id="${member.relationId}" data-asso="${member.assoId}" data-member="${member.memberId}"></td>
                            <td>${member_index+1}</td>
                            <td><img src="${(member.imgUrl)!'/images/default.jpg'}" width="50px" id="imgUrl"></td>
                            <td>${member.number!}</td>
                            <td>${(member.username)!}</td>
                            <td>${(member.academy)!}</td>
                            <td>${(member.major)!}</td>
                            <td>${(member.className)!}</td>
                            <td>${(member.sex)!}</td>
                            <td>${(member.birth?string('yyyy-MM-dd'))!}</td>
                            <td>${member.mobile!}</td>
                            <td>${member.email!}</td>
                            <td>${(member.deptname)!'普通成员'}</td>
                            <td>${(member.passTime?string('yyyy-MM-dd'))!}</td>
                            <td>
                                 <#if (member.isAgree!) == 0>
                                    待审核
                                 </#if>
                                <#if (member.isAgree!) == 1>
                                    通过
                                </#if>
                                <#if (member.isAgree!) == 2>
                                    拒绝
                                </#if>
                            </td>
                            <td>
                                <a href="javascript:;" class="btn btn-info btn-xs btn_redirect" data-json='${member.jsonString!}'>
                                    <span class="glyphicon glyphicon-pencil"></span> 编辑
                                </a>
                                <a href="javascript:;" class="btn btn-danger btn-xs btn_delete" data-id="${member.relationId}" data-asso="${member.assoId}">
                                    <span class="glyphicon glyphicon-trash"></span> 删除
                                </a>
                            </td>
                            <td>
                                <a class="btn btn-success btn-xs hotBtn1" href="javascript:;" data-hot='1' data-id="${member.id}" data-asso="${member.assoId}">
                                    <span class="glyphicon glyphicon-minus-sign"></span> 审核通过
                                </a>

                                <a class="btn btn-danger btn-xs hotBtn2" href="JavaScript:;" data-hot="2" data-id="${member.id}" data-asso="${member.assoId}">
                                    <span class="glyphicon glyphicon-tag"></span>审核拒绝
                                </a>
                            </td>
                        </tr>
                    </#list>
                </table>
                <!--分页-->
                <#include "../../common/page.ftl">
            </div>
        </section>
    </div>
    <#include "../../common/footer.ftl">
</div>

<!-- 大图显示 -->
<div id="ShowImage_Form" class="modal fade" >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body" >
            </div>
        </div>
    </div>
</div>


<script>
    $("table img").click(function(){
        var src = $(this).attr("src");
        $("#ShowImage_Form .modal-body").html("<img src='"+src+"' class='carousel-inner img-responsive img-rounded' />");
        $("#ShowImage_Form").modal('show');
    })
</script>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">导入</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/member/importXls.do" method="post" id="editForm">
                    <input type="hidden" name="id">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-3 control-label"></label>
                        <div class="col-sm-6">
                            <input type="file" name="file">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <div class="col-sm-3"></div>
                        <div class="col-sm-6">
                            <a href="/xlstemplates/member.xls" class="btn btn-success" >
                            <span class="glyphicon glyphicon-download"></span> 下载模板
                            </a>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary btn-submit">保存</button>
            </div>
        </div>
    </div>
</div>

<!-- Modal模态框 -->
<div class="modal fade" id="inputSynModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalSynLabel">社团成员新增/编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/member/saveOrUpdateRelation.do" method="post" id="editForm2">
                    <input type="hidden" name="id">
                    <input type="hidden" name="relationId">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="applicant" class="col-sm-3 control-label">学号：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="number" name="number">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="applicant" class="col-sm-3 control-label">姓名：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="name" name="name">
                        </div>
                    </div>


                    <div class="form-group">
                        <label for="email" class="col-sm-3 control-label">部门：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="deptname" name="deptname"
                                   placeholder="请输入部门">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="isAgree" class="col-sm-3 control-label">状态：</label>
                        <div class="col-sm-6">
                            <select class="form-control" id="isAgree" name="isAgree">
                                <option value="-1">全部</option>
                                <option value="0">待审核</option>
                                <option value="1">审核成功</option>
                                <option value="2">审核拒绝</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="passTime" class="col-sm-3 control-label">入会时间：</label>
                        <div class="col-sm-6 input-daterange" id="datepicker">
                            <input type="text" class="input-sm form-control" name="passTime"/>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary btn-submit2">保存</button>
            </div>
        </div>
    </div>
</div>

</body>
</html>
